<?php /*
 * 1626cms 企業會員中心
 * ============================================================================
 * 版權所有: 1626網絡，并保留所有權利。
 * 網站地址: http://www.1626.com；
 * ----------------------------------------------------------------------------
 * 這不是一個自由軟件！您只能在不用于商業目的的前提下對程序代碼進行修改和
 * 使用；不允許對程序代碼以任何形式任何目的的再發布。
 * ============================================================================
*/
define ( 'IN_QISHI', true );
$page_select = "user";
require_once ('./include/common.inc.php');
require_once (QISHI_ROOT_PATH . 'include/mysql.class.php');
$db = new mysql ( $dbhost, $dbuser, $dbpass, $dbname );
unset ( $dbhost, $dbuser, $dbpass, $dbname );
if ($_SESSION ['utype'] != '1')
	showmsg ( '請先登陸企業會員，再進行相關操作！', 1 );
if ($_SESSION ['uid'] == '' || $_SESSION ['username'] == '' || $_SESSION ['utype'] != '1')
	header ( "Location: user.php" );
require_once (QISHI_ROOT_PATH . 'include/fun_category.php');
require_once (QISHI_ROOT_PATH . 'include/fun_user_company.php');
require_once (QISHI_ROOT_PATH . 'include/fun_jobs.php');
$act = ! empty ( $_REQUEST ['act'] ) ? trim ( $_REQUEST ['act'] ) : 'index';
$smarty->caching = false;
$smarty->assign ( 'count_jobs', count_jobs ( $_SESSION ['uid'] ) ); //已發布職位總數
$smarty->assign ( 'count_jobs_apply', count_jobs_apply ( $_SESSION ['uid'] ) ); //收到的職位申請總數
$smarty->assign ( 'count_down_resume', count_down_resume ( $_SESSION ['uid'] ) ); //已下載簡歷總數
$smarty->assign ( 'count_invitation_interview', count_invitation_interview ( $_SESSION ['uid'] ) ); //發起邀請總數
$smarty->assign ( 'count_resume_library', count_resume_library ( $_SESSION ['uid'] ) ); //人才庫總數
$user_status = get_user_status ( $_SESSION ['uid'] );
$smarty->assign ( 'user_status', $user_status ); //會員的狀態
if ($user_status == "2" && $act != 'index' && $act != 'user_status' && $act != 'user_status_save') {
	showmsg ( '您的賬號處于暫停狀態，請先設為正常后進行操作！', 1 );
}
//*************************************************服務中心首頁**********************
//服務中心首頁
if ($act == 'index') {
	$smarty->assign ( 'title', '企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->assign ( 'username', $_SESSION ['username'] );
	$smarty->assign ( 'points', get_user_points ( $_SESSION ['uid'] ) );
	$smarty->assign ( 'company_profile', get_company_profile ( $_SESSION ['uid'] ) );
	$smarty->display ( 'member_company/company_index.htm' );
}
//*************************************************職位管理**********************
//添加職位
if ($act == 'addjobs') {
	$company_profile = get_company_profile ( $_SESSION ['uid'] );
	if ($company_profile) {
		$smarty->assign ( 'title', '發布新的職位 - 企業會員中心 - ' . $_CFG ['site_name'] );
		$smarty->assign ( 'pointsc_total', get_user_points ( $_SESSION ['uid'] ) );
		$smarty->assign ( 'points', get_cache ( 'members_points_rule' ) );
		$smarty->assign ( 'company_profile', $company_profile );
		$smarty->assign ( 'nature', get_jobs_nature () );
		$smarty->assign ( 'category', get_jobs_category () );
		$smarty->assign ( 'district', get_jobs_area () );
		$smarty->assign ( 'education', get_jobs_education () );
		$smarty->assign ( 'experience', get_jobs_experience () );
		$smarty->assign ( 'trade', get_jobs_trade () );
		$smarty->assign ( 'wage', get_jobs_wage () );
		$smarty->display ( 'member_company/company_addjobs.htm' );
	} else {
		$link [0] ['text'] = "完善企業資料";
		$link [0] ['href'] = '?act=company_profile';
		showmsg ( "為了達到更好的招聘效果，請先完善您的企業資料！", 1, $link );
	}
}
//保存添加的職位
if ($act == 'addjobs_save') {
	$_POST = htmldecode ( $_POST );
	$company_audit = get_company_profile ( $_SESSION ['uid'] ); //獲取會員認證狀態
	$link [1] ['text'] = "會員中心首頁";
	$link [1] ['href'] = "?";
	//計算積分結束
	$tablename = table ( 'jobs' );
	$tablename_attachment = table ( 'jobs_attachment' );
	$tablename_shiftwork = table ( 'jobs_shiftwork' );
	$tablename_skills = table ( 'jobs_skills' );
	$setsqlarr = array ();
	$setsqlarr_contents = array ();
	$setsqlarr_shiftwork = array ();
	
	/*
$setsqlarr['company_name_en']=trim($_POST['company_name_en']);
$setsqlarr['company_name_cn']=trim($_POST['company_name_cn']);
if('' == $setsqlarr['company_name_cn'] && '' == $setsqlarr['company_name_en'])
{
	showmsg('您沒有輸入公司名稱！',1);
}
$setsqlarr['trade']=trim($_POST['trade'])?trim($_POST['trade']):showmsg('您沒有輸入所屬行業！',1);
$setsqlarr['trade_option']=trim($_POST['trade_option']);
$setsqlarr['stuff_number']=trim($_POST['stuff_number'])?trim($_POST['stuff_number']):showmsg('您沒有輸入現有僱員人數！',1);
$setsqlarr['school_number']=trim($_POST['school_number']);
$setsqlarr['reg_number_pre']=trim($_POST['reg_number_pre']);
$setsqlarr['reg_number_suf']=trim($_POST['reg_number_suf']);

$setsqlarr['contact_gender_en']=trim($_POST['contact_gender_en'])?trim($_POST['contact_gender_en']):1;
$setsqlarr['contact_gender_cn']=trim($_POST['contact_gender_cn'])?trim($_POST['contact_gender_cn']):1;
$setsqlarr['contact_en']=trim($_POST['contact_en']);
$setsqlarr['contact_cn']=trim($_POST['contact_cn']);
if('' == $setsqlarr['contact_cn'] && '' == $setsqlarr['contact_en'])
{
	showmsg('您沒有輸入聯絡人姓名！',1);
}
$setsqlarr['telephone']=trim($_POST['telephone']);
$setsqlarr['telephone_inline']=trim($_POST['telephone_inline']);
$setsqlarr['telephone_option']=trim($_POST['telephone_option'])?trim($_POST['telephone_option']):1;
if('' == $setsqlarr['telephone'] && '' == $setsqlarr['telephone_inline'])
{
	showmsg('您沒有輸入電話號碼！',1);
}
$setsqlarr['email']=trim($_POST['email'])?trim($_POST['email']):showmsg('您沒有輸入聯系郵箱！',1);
$setsqlarr['address_1_en']=trim($_POST['address_1_en']);
$setsqlarr['address_2_en']=trim($_POST['address_2_en']);
$setsqlarr['address_3_en']=trim($_POST['address_3_en']);
$setsqlarr['address_1_cn']=trim($_POST['address_1_cn']);
$setsqlarr['address_2_cn']=trim($_POST['address_2_cn']);
$setsqlarr['address_3_cn']=trim($_POST['address_3_cn']);
if('' == $setsqlarr['address_1_en'] && '' == $setsqlarr['address_2_en'] && '' == $setsqlarr['address_3_en']
	&&'' == $setsqlarr['address_1_cn'] && '' == $setsqlarr['address_2_cn'] && '' == $setsqlarr['address_3_cn'])
{
	showmsg('您沒有輸入公司地址！',1);
}*/
	//======================================================================//
	$setsqlarr ['uid'] = trim ( $_SESSION ['uid'] );
	$setsqlarr ['jobs_name_cn'] = trim ( $_POST ['jobs_name_cn'] );
	$setsqlarr ['jobs_name_en'] = trim ( $_POST ['jobs_name_en'] );
	if ('' == $setsqlarr ['jobs_name_en'] && '' == $setsqlarr ['jobs_name_cn']) {
		showmsg ( '您沒有輸入職位空缺名稱！', 1 );
	}
	$setsqlarr ['jobs_description_cn'] = trim ( $_POST ['jobs_description_cn'] );
	$setsqlarr ['jobs_description_en'] = trim ( $_POST ['jobs_description_en'] );
	if ('' == $setsqlarr ['jobs_description_cn'] && '' == $setsqlarr ['jobs_description_en']) {
		showmsg ( '您沒有輸入職位描述！', 1 );
	}
	$setsqlarr ['jobs_request'] = trim ( $_POST ['jobs_request'] ) ? trim ( $_POST ['jobs_request'] ) : showmsg ( '您沒有選擇申請方法！', 1 );
	$setsqlarr ['jobs_amount'] = trim ( $_POST ['jobs_amount'] ) ? trim ( $_POST ['jobs_amount'] ) : showmsg ( '您沒有輸入空缺數目！', 1 );
	$setsqlarr ['jobs_employ_type'] = trim ( $_POST ['jobs_employ_type'] ) ? trim ( $_POST ['jobs_employ_type'] ) : showmsg ( '您沒有選擇聘用形式！', 1 );
	$setsqlarr ['jobs_nature'] = intval ( $_POST ['jobs_nature'] ) ? intval ( $_POST ['jobs_nature'] ) : showmsg ( '您沒有選擇聘用形式！', 1 );
	$setsqlarr ['jobs_week_from'] = trim ( $_POST ['jobs_week_from'] ) ? trim ( $_POST ['jobs_week_from'] ) : showmsg ( '您沒有輸入每週工作天數！', 1 );
	$setsqlarr ['jobs_week_to'] = trim ( $_POST ['jobs_week_to'] ) ? trim ( $_POST ['jobs_week_to'] ) : showmsg ( '您沒有輸入每週工作天數！', 1 );
	if (2 == $_POST ['jobs_employ_type'] || 3 == $_POST ['jobs_employ_type']) {
		if (1 == $_POST ['jobs_hire_period']) {
			if ('' == $_POST ['jobs_hire_period_content']) {
				showmsg ( '您沒有輸入臨時工或暑期工工作期！', 1 );
			}
		}
		if (2 == $_POST ['jobs_hire_period']) {
			if ('' == $_POST ['jobs_hire_periodfrom'] || '' == $_POST ['jobs_hire_periodto']) {
				showmsg ( '您沒有輸入臨時工工作期！', 1 );
			}
		}
		$setsqlarr ['jobs_hire_period'] = $_POST ['jobs_hire_period'];
		$setsqlarr ['jobs_hire_periodfrom'] = $_POST ['jobs_hire_periodfrom'];
		$setsqlarr ['jobs_hire_periodto'] = $_POST ['jobs_hire_periodto'];
		$setsqlarr ['jobs_hire_period_content'] = $_POST ['jobs_hire_period_content'];
	}
	$setsqlarr ['jobs_hour_from'] = trim ( $_POST ['jobs_hour_from'] ) ? trim ( $_POST ['jobs_hour_from'] ) : showmsg ( '您沒有輸入每天工作時數！', 1 );
	$setsqlarr ['jobs_hour_to'] = trim ( $_POST ['jobs_hour_to'] ) ? trim ( $_POST ['jobs_hour_to'] ) : showmsg ( '您沒有輸入每天工作時數！', 1 );
	$setsqlarr ['jobs_shift'] = trim ( $_POST ['jobs_shift'] ) ? trim ( $_POST ['jobs_shift'] ) : showmsg ( '您沒有選擇需輪班！', 1 );
	
	if (count ( $_POST ['jobs_rest_day'] ) > 0) {
		$setsqlarr ['jobs_rest_day'] = implode ( '|', $_POST ['jobs_rest_day'] );
	} else {
		showmsg ( '您沒有選擇休息日！', 1 );
	}
	$setsqlarr ['jobs_address'] = trim ( $_POST ['jobs_address'] ) ? trim ( $_POST ['jobs_address'] ) : showmsg ( '您沒有輸入工作地點！', 1 );
	$setsqlarr ['jobs_wage_from'] = trim ( $_POST ['jobs_wage_from'] ) ? trim ( $_POST ['jobs_wage_from'] ) : showmsg ( '您沒有輸入基本薪金！', 1 );
	$setsqlarr ['jobs_wage_to'] = trim ( $_POST ['jobs_wage_to'] ) ? trim ( $_POST ['jobs_wage_to'] ) : showmsg ( '您沒有輸入基本薪金！', 1 );
	$setsqlarr ['jobs_wage_per'] = trim ( $_POST ['jobs_wage_per'] ) ? trim ( $_POST ['jobs_wage_per'] ) : 'month';
	$setsqlarr ['jobs_wage_double'] = trim ( $_POST ['jobs_wage_double'] ) ? trim ( $_POST ['jobs_wage_double'] ) : 0;
	$setsqlarr ['jobs_hour_other'] = trim ( $_POST ['jobs_hour_other'] ) ? trim ( $_POST ['jobs_hour_other'] ) : '';
	
	$setsqlarr ['jobs_wage_memo'] = trim ( $_POST ['jobs_wage_memo'] ) ? trim ( $_POST ['jobs_wage_memo'] ) : '';
	$setsqlarr ['jobs_education'] = trim ( $_POST ['jobs_education'] ) ? trim ( $_POST ['jobs_education'] ) : '';
	$setsqlarr ['jobs_education_option'] = trim ( $_POST ['jobs_education_option'] ) ? trim ( $_POST ['jobs_education_option'] ) : '';
	$setsqlarr ['jobs_speak_can'] = trim ( $_POST ['jobs_speak_can'] ) ? trim ( $_POST ['jobs_speak_can'] ) : '';
	$setsqlarr ['jobs_speak_en'] = trim ( $_POST ['jobs_speak_en'] ) ? trim ( $_POST ['jobs_speak_en'] ) : '';
	$setsqlarr ['jobs_speak_cn'] = trim ( $_POST ['jobs_speak_cn'] ) ? trim ( $_POST ['jobs_speak_cn'] ) : '';
	
	$setsqlarr ['jobs_read_cn'] = trim ( $_POST ['jobs_read_cn'] ) ? trim ( $_POST ['jobs_read_cn'] ) : '';
	$setsqlarr ['jobs_read_en'] = trim ( $_POST ['jobs_read_en'] ) ? trim ( $_POST ['jobs_read_en'] ) : '';
	$setsqlarr ['jobs_other_cn'] = trim ( $_POST ['jobs_other_cn'] ) ? trim ( $_POST ['jobs_other_cn'] ) : '';
	$setsqlarr ['jobs_other_en'] = trim ( $_POST ['jobs_other_en'] ) ? trim ( $_POST ['jobs_other_en'] ) : '';
	$setsqlarr ['jobs_other_level'] = trim ( $_POST ['jobs_other_level'] ) ? trim ( $_POST ['jobs_other_level'] ) : '';
	$setsqlarr ['jobs_require_cn'] = trim ( $_POST ['jobs_require_cn'] ) ? trim ( $_POST ['jobs_require_cn'] ) : '';
	$setsqlarr ['jobs_require_en'] = trim ( $_POST ['jobs_require_en'] ) ? trim ( $_POST ['jobs_require_en'] ) : '';
	
	$setsqlarr ['jobs_need_experience'] = intval ( $_POST ['jobs_need_experience'] ) ? intval ( $_POST ['jobs_need_experience'] ) : 2;
	if (1 == $setsqlarr ['jobs_need_experience']) {
		$setsqlarr ['jobs_year_from'] = $_POST ['year_from'];
		$setsqlarr ['jobs_month_from'] = $_POST ['month_from'];
	}
	else 
	{
		$setsqlarr ['jobs_year_from'] = 0;
		$setsqlarr ['jobs_month_from'] = 0;
	}
	$j_exp = '';
	if($_POST['jobs_experience'])
	{
		foreach($_POST['jobs_experience'] as $je)
		{
			if($j_exp == '')
			{
				$j_exp = $je;
			}
			else 
			{
				$j_exp = $j_exp. '|'. $je;
			}
		}
	}
	$setsqlarr ['jobs_experience'] = $j_exp;
	
	$setsqlarr ['jobs_speak_canfirst'] = $_POST ['jobs_speak_canfirst'];
	$setsqlarr ['jobs_speak_cnfirst'] = $_POST ['jobs_speak_cnfirst'];
	$setsqlarr ['jobs_speak_enfirst'] = $_POST ['jobs_speak_enfirst'];
	$setsqlarr ['jobs_boss'] = trim ( $_POST ['jobs_boss'] ) ? trim ( $_POST ['jobs_boss'] ) : showmsg ( '您沒有輸入公司代表/僱主姓名！', 1 );
	
	//職位地點添加
	$setsqlarr ['district'] = $_POST ['district'];
	//
	$setsqlarr ['addtime'] = $timestamp;
	$setsqlarr ['refreshtime'] = $timestamp;
	if ($company_audit ['audit'] == 1) //根據認證狀態設置是否需要審核
{
		$_CFG ['audit_verify'] == 1 ? $setsqlarr ['audit'] = 2 : $setsqlarr ['audit'] = 1;
	} else {
		$_CFG ['audit_unexamined'] == 1 ? $setsqlarr ['audit'] = 2 : $setsqlarr ['audit'] = 1;
	}
	//添加職位信息
	$pid = inserttable ( $tablename, $setsqlarr, true );
	! $pid ? showmsg ( "添加失敗！", 0 ) : '';
	
	if (1 == $setsqlarr ['jobs_shift']) {
		foreach ( $_POST ['jobs_hour_opt'] as $value ) {
			$jobs_hour_opt [] = trim ( $value ) ? trim ( $value ) : '';
		}
		foreach ( $_POST ['jobs_hour_opt2'] as $value2 ) {
			$jobs_hour_opt2 [] = trim ( $value2 ) ? trim ( $value2 ) : '';
		}
		foreach ( $_POST ['jobs_mm_opt'] as $value3 ) {
			$jobs_mm_opt [] = trim ( $value3 ) ? trim ( $value3 ) : '';
		}
		foreach ( $_POST ['jobs_mm_opt2'] as $value4 ) {
			$jobs_mm_opt2 [] = trim ( $value4 ) ? trim ( $value4 ) : '';
		}
		foreach ( $_POST ['jobs_ss_opt'] as $value5 ) {
			$jobs_ss_opt [] = trim ( $value5 ) ? trim ( $value5 ) : '';
		}
		foreach ( $_POST ['jobs_ss_opt2'] as $value6 ) {
			$jobs_ss_opt2 [] = trim ( $value6 ) ? trim ( $value6 ) : '';
		}
		if (isset ( $jobs_hour_opt ) && count ( $jobs_hour_opt ) > 0) {
			foreach ( $jobs_hour_opt as $k => $v ) {
				$setsqlarr_shiftwork ['jobs_hour_opt'] = $jobs_hour_opt [$k];
				$setsqlarr_shiftwork ['jobs_hour_opt2'] = $jobs_hour_opt2 [$k];
				$setsqlarr_shiftwork ['jobs_mm_opt'] = $jobs_mm_opt [$k];
				$setsqlarr_shiftwork ['jobs_mm_opt2'] = $jobs_mm_opt2 [$k];
				$setsqlarr_shiftwork ['jobs_ss_opt'] = $jobs_ss_opt [$k];
				$setsqlarr_shiftwork ['jobs_ss_opt2'] = $jobs_ss_opt2 [$k];
				$setsqlarr_shiftwork ['job_id'] = $pid;
				if ('' != trim ( $jobs_hour_opt [$k] ) || '' != trim ( $jobs_hour_opt2 [$k] ) || '' != trim ( $jobs_mm_opt [$k] ) || '' != trim ( $jobs_mm_opt2 [$k] ) || '' != trim ( $jobs_ss_opt [$k] ) || '' != trim ( $jobs_ss_opt2 [$k] )) {
					! inserttable ( table ( 'jobs_shiftwork' ), $setsqlarr_shiftwork ) ? showmsg ( "添加失敗！", 0 ) : '';
				}
			}
		}
	}
	
	foreach ( $_POST ['jobs_other_wage'] as $i ) {
		$jobs_other_wage [] = trim ( $i ) ? trim ( $i ) : '';
	}
	foreach ( $_POST ['jobs_other_wageopt'] as $i2 ) {
		$jobs_other_wageopt [] = trim ( $i2 ) ? trim ( $i2 ) : '';
	}
	foreach ( $_POST ['jobs_other_wageday'] as $i3 ) {
		$jobs_other_wageday [] = trim ( $i3 ) ? trim ( $i3 ) : '';
	}
	if (isset ( $jobs_other_wage ) && count ( $jobs_other_wage ) > 0) {
		foreach ( $jobs_other_wage as $k2 => $v2 ) {
			$setsqlarr_walfare ['jobs_other_wage'] = $jobs_other_wage [$k2];
			$setsqlarr_walfare ['jobs_other_wageopt'] = $jobs_other_wageopt [$k2];
			$setsqlarr_walfare ['jobs_other_wageday'] = $jobs_other_wageday [$k2];
			$setsqlarr_walfare ['job_id'] = $pid;
			if ('' != trim ( $jobs_other_wageday [$k2] ) || '' != trim ( $jobs_other_wageopt [$k2] ) || '' != trim ( $jobs_other_wage [$k2] )) {
				! inserttable ( table ( 'jobs_welfare' ), $setsqlarr_walfare ) ? showmsg ( "添加失敗！", 0 ) : '';
			}
		}
	}
	if (isset ( $_FILES ['attachment'] ) && count ( $_FILES ['attachment'] ) > 0) {
		require_once (QISHI_ROOT_PATH . 'include/upload_attachment.php');
		foreach ( $_FILES ['attachment'] ['name'] as $fkey => $file ) {
			if ($file) {
				$attachment_dir = substr ( $_CFG ['attachment_dir'], mb_strlen ( $_CFG ['site_dir'] ) ); //絕對路徑轉化成相對路徑 
				$attachment_parm = _asUpFiles ( $attachment_dir, $_FILES ['attachment'] ['tmp_name'] [$fkey], $file, $_FILES ['attachment'] ['size'] [$fkey], $max_size = 5120, $type = '', true );
				if ($attachment_parm) {
					inserttable ( table ( 'jobs_attachment' ), array ('job_id' => $pid, 'user_id' => $_SESSION ['uid'], 'name' => $attachment_parm ['name'], 'path' => $attachment_parm ['path'] ) );
				}
			}
		}
	}
	
	//添加職位點擊次數
	$setsqlarr_click ['pid'] = $pid;
	$setsqlarr_click ['click'] = 1;
	! inserttable ( table ( 'jobs_click' ), $setsqlarr_click ) ? showmsg ( "添加失敗！", 0 ) : '';
	$link [0] ['text'] = "已發布的職位";
	$link [0] ['href'] = '?act=jobs';
	$link [1] ['text'] = "繼續發布職位";
	$link [1] ['href'] = '?act=addjobs';
	$link [2] ['text'] = "會員中心首頁";
	$link [2] ['href'] = "?";
	unset ( $setsqlarr_contents, $setsqlarr_contact, $setsqlarr );
	refresh_company ( $_SESSION ['uid'] ); //刷新企業
	showmsg ( "發布成功！", 2, $link );
}
//刪除,刷新,屏蔽，激活，崗位
if ($act == 'jobs_perform') {
	$yid = trim ( $_POST ['y_id'] ) ? $_POST ['y_id'] : showmsg ( "你沒有選擇職位！", 1 );
	$refresh = trim ( $_POST ['refresh'] );
	$delete = trim ( $_POST ['delete'] );
	$delete ? (! del_jobs ( $yid, $_SESSION ['uid'] ) ? showmsg ( "刪除失敗！", 0 ) : showmsg ( "刪除成功！", 2 )) : '';
	$refresh ? (! refresh_jobs ( $yid, $_SESSION ['uid'] ) ? showmsg ( "刷新失敗！", 0 ) : showmsg ( "刷新成功！", 2 )) : '';
	trim ( $_POST ['display1'] ) ? (! activate_jobs ( $yid, 1, $_SESSION ['uid'] ) ? showmsg ( "設置失敗！", 0 ) : showmsg ( "設置成功！", 2 )) : '';
	trim ( $_POST ['display2'] ) ? (! activate_jobs ( $yid, 2, $_SESSION ['uid'] ) ? showmsg ( "設置失敗！", 0 ) : showmsg ( "設置成功！", 2 )) : '';
}
//已發布的職位
if ($act == 'jobs') {
	$audit = trim ( $_GET ['audit'] );
	$wheresql = " WHERE uid='" . $_SESSION ['uid'] . "' ";
	if ($audit != '' && is_numeric ( $audit )) {
		$wheresql .= " AND audit='" . $audit . "' ";
	}
	require_once (QISHI_ROOT_PATH . 'include/page.class.php');
	$perpage = 10;
	$total_sql = "SELECT COUNT(*) AS num FROM " . table ( 'jobs' ) . $wheresql;
	$total_val = get_total ( $total_sql );
	$page = new page ( array ('total' => $total_val, 'perpage' => $perpage ) );
	$currenpage = $page->nowindex;
	$offset = ($currenpage - 1) * $perpage;
	$smarty->assign ( 'title', '已發布的信息管理 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->assign ( 'act', $act );
	$smarty->assign ( 'audit', $audit );
	$smarty->assign ( 'jobs', get_jobs ( $offset, $perpage, $wheresql ) );
	if ($total_val > $perpage) {
		$smarty->assign ( 'page', $page->show ( 3 ) ); //分頁符
	}
	$smarty->display ( 'member_company/company_jobs.htm' );
}
//修改職位
if ($act == 'editjobs') {
	$company_profile = get_company_profile ( $_SESSION ['uid'] );
	$jobs = get_jobs_one ( trim ( $_GET ['id'] ) );
	$jobs ['jobs_rest_day'] = explode ( '|', $jobs ['jobs_rest_day'] );
	$jobs ['jobs_experience'] = explode ( '|', $jobs ['jobs_experience'] );
	$smarty->assign ( 'title', '修改職位 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->assign ( 'company_profile', $company_profile );
	$smarty->assign ( 'jobs', $jobs );
	$smarty->assign ( 'education', get_jobs_education () );
	$smarty->assign ( 'attachment', get_jobs_attachment ( trim ( $_GET ['id'] ) ) );
	$smarty->assign ( 'trade', get_jobs_trade () );
	$smarty->assign ( 'jobs_other_wage', get_jobs_other_wage ( trim ( $_GET ['id'] ) ) );
	$smarty->assign ( 'nature', get_jobs_nature () );
	$smarty->assign ( 'shiftwork', get_jobs_shiftwork ( trim ( $_GET ['id'] ) ) );
	$smarty->display ( 'member_company/company_editjobs.htm' );
}
//保存修改的職位
if ($act == 'editjobs_save') {
	$_POST = htmldecode ( $_POST );
	$id = trim ( $_POST ['id'] );
	if (intval ( $id ) != $id)
		showmsg ( '參數錯誤！', 0 );
	
	$company_audit = get_company_profile ( $_SESSION ['uid'] ); //獲取會員認證狀態
	$link [1] ['text'] = "會員中心首頁";
	$link [1] ['href'] = "?";
	//計算積分結束
	$tablename = table ( 'jobs' );
	$tablename_attachment = table ( 'jobs_attachment' );
	$tablename_shiftwork = table ( 'jobs_shiftwork' );
	$tablename_skills = table ( 'jobs_skills' );
	$setsqlarr = array ();
	$setsqlarr_contents = array ();
	$setsqlarr_shiftwork = array ();
	
	/*
$setsqlarr['company_name_en']=trim($_POST['company_name_en']);
$setsqlarr['company_name_cn']=trim($_POST['company_name_cn']);
if('' == $setsqlarr['company_name_cn'] && '' == $setsqlarr['company_name_en'])
{
	showmsg('您沒有輸入公司名稱！',1);
}
$setsqlarr['trade']=trim($_POST['trade'])?trim($_POST['trade']):showmsg('您沒有輸入所屬行業！',1);
$setsqlarr['trade_option']=trim($_POST['trade_option']);
$setsqlarr['stuff_number']=trim($_POST['stuff_number'])?trim($_POST['stuff_number']):showmsg('您沒有輸入現有僱員人數！',1);
$setsqlarr['school_number']=trim($_POST['school_number']);
$setsqlarr['reg_number_pre']=trim($_POST['reg_number_pre']);
$setsqlarr['reg_number_suf']=trim($_POST['reg_number_suf']);

$setsqlarr['contact_gender_en']=trim($_POST['contact_gender_en'])?trim($_POST['contact_gender_en']):1;
$setsqlarr['contact_gender_cn']=trim($_POST['contact_gender_cn'])?trim($_POST['contact_gender_cn']):1;
$setsqlarr['contact_en']=trim($_POST['contact_en']);
$setsqlarr['contact_cn']=trim($_POST['contact_cn']);
if('' == $setsqlarr['contact_cn'] && '' == $setsqlarr['contact_en'])
{
	showmsg('您沒有輸入聯絡人姓名！',1);
}
$setsqlarr['telephone']=trim($_POST['telephone']);
$setsqlarr['telephone_inline']=trim($_POST['telephone_inline']);
$setsqlarr['telephone_option']=trim($_POST['telephone_option'])?trim($_POST['telephone_option']):1;
if('' == $setsqlarr['telephone'] && '' == $setsqlarr['telephone_inline'])
{
	showmsg('您沒有輸入電話號碼！',1);
}
$setsqlarr['email']=trim($_POST['email'])?trim($_POST['email']):showmsg('您沒有輸入聯系郵箱！',1);
$setsqlarr['address_1_en']=trim($_POST['address_1_en']);
$setsqlarr['address_2_en']=trim($_POST['address_2_en']);
$setsqlarr['address_3_en']=trim($_POST['address_3_en']);
$setsqlarr['address_1_cn']=trim($_POST['address_1_cn']);
$setsqlarr['address_2_cn']=trim($_POST['address_2_cn']);
$setsqlarr['address_3_cn']=trim($_POST['address_3_cn']);
if('' == $setsqlarr['address_1_en'] && '' == $setsqlarr['address_2_en'] && '' == $setsqlarr['address_3_en']
	&&'' == $setsqlarr['address_1_cn'] && '' == $setsqlarr['address_2_cn'] && '' == $setsqlarr['address_3_cn'])
{
	showmsg('您沒有輸入公司地址！',1);
}*/
	//======================================================================//
	$setsqlarr ['uid'] = trim ( $_SESSION ['uid'] );
	$setsqlarr ['jobs_name_cn'] = trim ( $_POST ['jobs_name_cn'] );
	$setsqlarr ['jobs_name_en'] = trim ( $_POST ['jobs_name_en'] );
	if ('' == $setsqlarr ['jobs_name_en'] && '' == $setsqlarr ['jobs_name_cn']) {
		showmsg ( '您沒有輸入職位空缺名稱！', 1 );
	}
	$setsqlarr ['jobs_description_cn'] = trim ( $_POST ['jobs_description_cn'] );
	$setsqlarr ['jobs_description_en'] = trim ( $_POST ['jobs_description_en'] );
	if ('' == $setsqlarr ['jobs_description_cn'] && '' == $setsqlarr ['jobs_description_en']) {
		showmsg ( '您沒有輸入職位描述！', 1 );
	}
	$setsqlarr ['jobs_request'] = trim ( $_POST ['jobs_request'] ) ? trim ( $_POST ['jobs_request'] ) : showmsg ( '您沒有選擇申請方法！', 1 );
	$setsqlarr ['jobs_amount'] = trim ( $_POST ['jobs_amount'] ) ? trim ( $_POST ['jobs_amount'] ) : showmsg ( '您沒有輸入空缺數目！', 1 );
	$setsqlarr ['jobs_employ_type'] = trim ( $_POST ['jobs_employ_type'] ) ? trim ( $_POST ['jobs_employ_type'] ) : showmsg ( '您沒有選擇聘用形式！', 1 );
	$setsqlarr ['jobs_nature'] = intval ( $_POST ['jobs_nature'] ) ? intval ( $_POST ['jobs_nature'] ) : showmsg ( '您沒有選擇聘用形式！', 1 );
	$setsqlarr ['jobs_week_from'] = trim ( $_POST ['jobs_week_from'] ) ? trim ( $_POST ['jobs_week_from'] ) : showmsg ( '您沒有輸入每週工作天數！', 1 );
	$setsqlarr ['jobs_week_to'] = trim ( $_POST ['jobs_week_to'] ) ? trim ( $_POST ['jobs_week_to'] ) : showmsg ( '您沒有輸入每週工作天數！', 1 );
	if (2 == $_POST ['jobs_employ_type'] || 3 == $_POST ['jobs_employ_type']) {
		if (1 == $_POST ['jobs_hire_period']) {
			if ('' == $_POST ['jobs_hire_period_content']) {
				showmsg ( '您沒有輸入臨時工或暑期工工作期！', 1 );
			}
		}
		if (2 == $_POST ['jobs_hire_period']) {
			if ('' == $_POST ['jobs_hire_periodfrom'] || '' == $_POST ['jobs_hire_periodto']) {
				showmsg ( '您沒有輸入臨時工工作期！', 1 );
			}
		}
		$setsqlarr ['jobs_hire_period'] = $_POST ['jobs_hire_period'];
		$setsqlarr ['jobs_hire_periodfrom'] = $_POST ['jobs_hire_periodfrom'];
		$setsqlarr ['jobs_hire_periodto'] = $_POST ['jobs_hire_periodto'];
		$setsqlarr ['jobs_hire_period_content'] = $_POST ['jobs_hire_period_content'];
	}
	$setsqlarr ['jobs_need_experience'] = intval ( $_POST ['jobs_need_experience'] ) ? intval ( $_POST ['jobs_need_experience'] ) : 2;
	if (1 == $setsqlarr ['jobs_need_experience']) {
		$setsqlarr ['jobs_year_from'] = $_POST ['year_from'];
		$setsqlarr ['jobs_month_from'] = $_POST ['month_from'];
	}
	else 
	{
		$setsqlarr ['jobs_year_from'] = 0;
		$setsqlarr ['jobs_month_from'] = 0;
	}
	$setsqlarr ['jobs_speak_canfirst'] = $_POST ['jobs_speak_canfirst'];
	$setsqlarr ['jobs_speak_cnfirst'] = $_POST ['jobs_speak_cnfirst'];
	$setsqlarr ['jobs_speak_enfirst'] = $_POST ['jobs_speak_enfirst'];
	$setsqlarr ['jobs_hour_from'] = trim ( $_POST ['jobs_hour_from'] ) ? trim ( $_POST ['jobs_hour_from'] ) : showmsg ( '您沒有輸入每天工作時數！', 1 );
	$setsqlarr ['jobs_hour_to'] = trim ( $_POST ['jobs_hour_to'] ) ? trim ( $_POST ['jobs_hour_to'] ) : showmsg ( '您沒有輸入每天工作時數！', 1 );
	$setsqlarr ['jobs_shift'] = trim ( $_POST ['jobs_shift'] ) ? trim ( $_POST ['jobs_shift'] ) : showmsg ( '您沒有選擇需輪班！', 1 );
	if (count ( $_POST ['jobs_rest_day'] ) > 0) {
		$setsqlarr ['jobs_rest_day'] = implode ( '|', $_POST ['jobs_rest_day'] );
	} else {
		showmsg ( '您沒有選擇休息日！', 1 );
	}
	$setsqlarr ['jobs_address'] = trim ( $_POST ['jobs_address'] ) ? trim ( $_POST ['jobs_address'] ) : showmsg ( '您沒有輸入工作地點！', 1 );
	$setsqlarr ['jobs_wage_from'] = trim ( $_POST ['jobs_wage_from'] ) ? trim ( $_POST ['jobs_wage_from'] ) : showmsg ( '您沒有輸入基本薪金！', 1 );
	$setsqlarr ['jobs_wage_to'] = trim ( $_POST ['jobs_wage_to'] ) ? trim ( $_POST ['jobs_wage_to'] ) : showmsg ( '您沒有輸入基本薪金！', 1 );
	$setsqlarr ['jobs_wage_per'] = trim ( $_POST ['jobs_wage_per'] ) ? trim ( $_POST ['jobs_wage_per'] ) : 'month';
	$setsqlarr ['jobs_wage_double'] = trim ( $_POST ['jobs_wage_double'] ) ? trim ( $_POST ['jobs_wage_double'] ) : 0;
	$setsqlarr ['jobs_hour_other'] = trim ( $_POST ['jobs_hour_other'] ) ? trim ( $_POST ['jobs_hour_other'] ) : '';
	
	$setsqlarr ['jobs_wage_memo'] = trim ( $_POST ['jobs_wage_memo'] ) ? trim ( $_POST ['jobs_wage_memo'] ) : '';
	$setsqlarr ['jobs_education'] = trim ( $_POST ['jobs_education'] ) ? trim ( $_POST ['jobs_education'] ) : '';
	$setsqlarr ['jobs_education_option'] = trim ( $_POST ['jobs_education_option'] ) ? trim ( $_POST ['jobs_education_option'] ) : '';
	$setsqlarr ['jobs_speak_can'] = trim ( $_POST ['jobs_speak_can'] ) ? trim ( $_POST ['jobs_speak_can'] ) : '';
	$setsqlarr ['jobs_speak_en'] = trim ( $_POST ['jobs_speak_en'] ) ? trim ( $_POST ['jobs_speak_en'] ) : '';
	$setsqlarr ['jobs_speak_cn'] = trim ( $_POST ['jobs_speak_cn'] ) ? trim ( $_POST ['jobs_speak_cn'] ) : '';
	
	$setsqlarr ['jobs_read_cn'] = trim ( $_POST ['jobs_read_cn'] ) ? trim ( $_POST ['jobs_read_cn'] ) : '';
	$setsqlarr ['jobs_read_en'] = trim ( $_POST ['jobs_read_en'] ) ? trim ( $_POST ['jobs_read_en'] ) : '';
	$setsqlarr ['jobs_other_cn'] = trim ( $_POST ['jobs_other_cn'] ) ? trim ( $_POST ['jobs_other_cn'] ) : '';
	$setsqlarr ['jobs_other_en'] = trim ( $_POST ['jobs_other_en'] ) ? trim ( $_POST ['jobs_other_en'] ) : '';
	$setsqlarr ['jobs_other_level'] = trim ( $_POST ['jobs_other_level'] ) ? trim ( $_POST ['jobs_other_level'] ) : '';
	$setsqlarr ['jobs_require_cn'] = trim ( $_POST ['jobs_require_cn'] ) ? trim ( $_POST ['jobs_require_cn'] ) : '';
	$setsqlarr ['jobs_require_en'] = trim ( $_POST ['jobs_require_en'] ) ? trim ( $_POST ['jobs_require_en'] ) : '';
	
	$j_exp = '';
	if($_POST['jobs_experience'])
	{
		foreach($_POST['jobs_experience'] as $je)
		{
			if($j_exp == '')
			{
				$j_exp = $je;
			}
			else 
			{
				$j_exp = $j_exp. '|'. $je;
			}
		}
	}
	$setsqlarr ['jobs_experience'] = $j_exp;
	$setsqlarr ['jobs_boss'] = trim ( $_POST ['jobs_boss'] ) ? trim ( $_POST ['jobs_boss'] ) : showmsg ( '您沒有輸入公司代表/僱主姓名！', 1 );
	//職位地點添加
	$setsqlarr ['district'] = $_POST ['district'];
	//	
	$setsqlarr ['addtime'] = $timestamp;
	$setsqlarr ['refreshtime'] = $timestamp;
	if ($company_audit ['audit'] == 1) //根據認證狀態設置是否需要審核
{
		$_CFG ['audit_verify'] == 1 ? $setsqlarr ['audit'] = 2 : $setsqlarr ['audit'] = 1;
	} else {
		$_CFG ['audit_unexamined'] == 1 ? $setsqlarr ['audit'] = 2 : $setsqlarr ['audit'] = 1;
	}
	//添加職位信息
	$wheresql = " id='" . $id . "' AND uid='" . $_SESSION ['uid'] . "' ";
	if (! updatetable ( $tablename, $setsqlarr, $wheresql ))
		showmsg ( "保存失敗！", 0 );
	
	if (1 == $setsqlarr ['jobs_shift']) {
		foreach ( $_POST ['jobs_hour_opt'] as $value ) {
			$jobs_hour_opt [] = trim ( $value ) ? trim ( $value ) : '';
		}
		foreach ( $_POST ['jobs_hour_opt2'] as $value2 ) {
			$jobs_hour_opt2 [] = trim ( $value2 ) ? trim ( $value2 ) : '';
		}
		foreach ( $_POST ['jobs_mm_opt'] as $value3 ) {
			$jobs_mm_opt [] = trim ( $value3 ) ? trim ( $value3 ) : '';
		}
		foreach ( $_POST ['jobs_mm_opt2'] as $value4 ) {
			$jobs_mm_opt2 [] = trim ( $value4 ) ? trim ( $value4 ) : '';
		}
		foreach ( $_POST ['jobs_ss_opt'] as $value5 ) {
			$jobs_ss_opt [] = trim ( $value5 ) ? trim ( $value5 ) : '';
		}
		foreach ( $_POST ['jobs_ss_opt2'] as $value6 ) {
			$jobs_ss_opt2 [] = trim ( $value6 ) ? trim ( $value6 ) : '';
		}
		if (isset ( $jobs_hour_opt ) && count ( $jobs_hour_opt ) > 0) {
			del_jobs_shiftwork ( $id );
			
			foreach ( $jobs_hour_opt as $k => $v ) {
				$setsqlarr_shiftwork ['jobs_hour_opt'] = $jobs_hour_opt [$k];
				$setsqlarr_shiftwork ['jobs_hour_opt2'] = $jobs_hour_opt2 [$k];
				$setsqlarr_shiftwork ['jobs_mm_opt'] = $jobs_mm_opt [$k];
				$setsqlarr_shiftwork ['jobs_mm_opt2'] = $jobs_mm_opt2 [$k];
				$setsqlarr_shiftwork ['jobs_ss_opt'] = $jobs_ss_opt [$k];
				$setsqlarr_shiftwork ['jobs_ss_opt2'] = $jobs_ss_opt2 [$k];
				$setsqlarr_shiftwork ['job_id'] = $id;
				if ('' != trim ( $jobs_hour_opt [$k] ) || '' != trim ( $jobs_hour_opt2 [$k] ) || '' != trim ( $jobs_mm_opt [$k] ) || '' != trim ( $jobs_mm_opt2 [$k] ) || '' != trim ( $jobs_ss_opt [$k] ) || '' != trim ( $jobs_ss_opt2 [$k] )) {
					! inserttable ( table ( 'jobs_shiftwork' ), $setsqlarr_shiftwork ) ? showmsg ( "添加失敗！", 0 ) : '';
				}
			}
		}
	}
	
	foreach ( $_POST ['jobs_other_wage'] as $i ) {
		$jobs_other_wage [] = trim ( $i ) ? trim ( $i ) : '';
	}
	foreach ( $_POST ['jobs_other_wageopt'] as $i2 ) {
		$jobs_other_wageopt [] = trim ( $i2 ) ? trim ( $i2 ) : '';
	}
	foreach ( $_POST ['jobs_other_wageday'] as $i3 ) {
		$jobs_other_wageday [] = trim ( $i3 ) ? trim ( $i3 ) : '';
	}
	if (isset ( $jobs_other_wage ) && count ( $jobs_other_wage ) > 0) {
		del_jobs_welfare ( $id );
		foreach ( $jobs_other_wage as $kj => $vj ) {
			$setsqlarr_walfare ['jobs_other_wage'] = $jobs_other_wage [$kj];
			$setsqlarr_walfare ['jobs_other_wageopt'] = $jobs_other_wageopt [$kj];
			$setsqlarr_walfare ['jobs_other_wageday'] = $jobs_other_wageday [$kj];
			$setsqlarr_walfare ['job_id'] = $id;
			if ('' != trim ( $jobs_other_wageday [$kj] ) || '' != trim ( $jobs_other_wageopt [$kj] ) || '' != trim ( $jobs_other_wage [$kj] )) {
				! inserttable ( table ( 'jobs_welfare' ), $setsqlarr_walfare ) ? showmsg ( "添加失敗！", 0 ) : '';
			}
		}
	}
	if (isset ( $_FILES ['attachment'] ) && count ( $_FILES ['attachment'] ) > 0) {
		//		del_jobs_attachment($id, $_CFG ['attachment_dir']);
		require_once (QISHI_ROOT_PATH . 'include/upload_attachment.php');
		foreach ( $_FILES ['attachment'] ['name'] as $fkey => $file ) {
			if ($file) {
				$attachment_dir = substr ( $_CFG ['attachment_dir'], mb_strlen ( $_CFG ['site_dir'] ) ); //絕對路徑轉化成相對路徑 
				$attachment_parm = _asUpFiles ( $attachment_dir, $_FILES ['attachment'] ['tmp_name'] [$fkey], $file, $_FILES ['attachment'] ['size'] [$fkey], $max_size = 5120, $type = '', true );
				if ($attachment_parm) {
					inserttable ( table ( 'jobs_attachment' ), array ('job_id' => $id, 'user_id' => $_SESSION ['uid'], 'name' => $attachment_parm ['name'], 'path' => $attachment_parm ['path'] ) );
				}
			}
		}
	}
	//$wheresql=" pid='".$id."' ";
	//$setsqlarr_contents['pid']=$id;
	//if (!updatetable($tablename_contents, $setsqlarr_contents,$wheresql)) showmsg("保存失敗！",0);
	//if (!updatetable($tablename_contact, $setsqlarr_contact,$wheresql)) showmsg("保存失敗！",0);
	unset ( $setsqlarr_contents, $setsqlarr_shiftwork, $setsqlarr );
	$link [0] ['text'] = "查看已發布職位";
	$link [0] ['href'] = '?act=jobs';
	$link [1] ['text'] = "查看修改結果";
	$link [1] ['href'] = '?act=editjobs&id=' . $id;
	$link [2] ['text'] = "會員中心首頁";
	$link [2] ['href'] = "?";
	showmsg ( "修改成功！", 2, $link );
}
//*************************************************招聘管理**********************
//收到的職位申請
if ($act == 'jobs_apply_list') {
	require_once (QISHI_ROOT_PATH . 'include/page.class.php');
	$wheresql = " WHERE company_uid='" . $_SESSION ['uid'] . "' ";
	$perpage = 10;
	$total_sql = "SELECT COUNT(*) AS num FROM " . table ( 'personal_jobs_apply' ) . $wheresql;
	$total_val = get_total ( $total_sql );
	$page = new page ( array ('total' => $total_val, 'perpage' => $perpage ) );
	$currenpage = $page->nowindex;
	$offset = ($currenpage - 1) * $perpage;
	$smarty->assign ( 'title', '收到的職位申請 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->assign ( 'jobs_apply', get_jobs_apply ( $offset, $perpage, $wheresql ) );
	if ($total_val > $perpage) {
		$smarty->assign ( 'page', $page->show ( 3 ) ); //分頁符
	}
	$smarty->display ( 'member_company/company_jobs_apply_list.htm' );
}
//詳細查看職位申請
if ($act == 'jobs_apply_show') {
	$smarty->assign ( 'jobs_apply', get_jobs_apply_one ( intval ( $_GET ['id'] ) ) ); //
	$smarty->assign ( 'title', '收到的職位申請 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->display ( 'member_company/company_jobs_apply_show.htm' );
}
//刪除職位申請
if ($act == 'jobs_apply_del') {
	$yid = trim ( $_REQUEST ['y_id'] ) ? $_REQUEST ['y_id'] : showmsg ( "你沒有選擇任何項目！", 1 );
	$delete = trim ( $_POST ['delete'] );
	$delete ? (! del_jobs_apply ( $yid, $_SESSION ['uid'] ) ? showmsg ( "刪除失敗！", 0 ) : showmsg ( "刪除成功！", 2 )) : '';
}
//下載簡歷
if ($act == 'down_resume') {
	$resume_id = $_GET ['resume_id'];
	if (intval ( $resume_id ) == $resume_id) {
		$link [0] ['text'] = "查看此簡歷";
		$link [0] ['href'] = $_SERVER ['HTTP_REFERER'];
		$link [1] ['text'] = "管理已下載簡歷";
		$link [1] ['href'] = '?act=down_resume_lsit';
		if (check_down_resumeid ( $resume_id, $_SESSION ['uid'] ))
			showmsg ( "此簡歷已經存在，請在“已下載簡歷中查看”！", 1 );
		$points_rule = get_cache ( 'members_points_rule' ); //消費規則
		$resumeusql = "select * from " . table ( 'resume' ) . " WHERE id ='$resume_id'";
		$resumeu = $db->getone ( $resumeusql ); //獲取簡歷名稱
		$points = $resumeu ['talent'] == '2' ? $points_rule ['resume_download_advanced'] : $points_rule ['resume_download'];
		if (get_user_points ( $_SESSION ['uid'] ) < $points)
			showmsg ( "你的" . $_CFG ['points_byname'] . "不足，請充值后下載", 1 );
		if (add_down_resume ( $resume_id, $_SESSION ['uid'], $points ))
			showmsg ( "下載成功！已保存至：會員中心 > 已下載簡歷", 2, $link, false );
		else
			showmsg ( "下載簡歷失敗！", 1 );
	}
}
//已下載簡歷列表
if ($act == 'down_resume_lsit') {
	require_once (QISHI_ROOT_PATH . 'include/page.class.php');
	$perpage = 10;
	$wheresql = " INNER JOIN  " . table ( 'resume' ) . " ON " . table ( 'company_down_resume' ) . ".company_uid=" . intval ( $_SESSION ['uid'] ) . " AND " . table ( 'company_down_resume' ) . ".resume_id=" . table ( 'resume' ) . ".id ";
	$total_sql = "SELECT COUNT(*) AS num FROM " . table ( 'company_down_resume' ) . $wheresql;
	$total_val = get_total ( $total_sql );
	$page = new page ( array ('total' => $total_val, 'perpage' => $perpage ) );
	$currenpage = $page->nowindex;
	$offset = ($currenpage - 1) * $perpage;
	$smarty->assign ( 'title', '已下載的簡歷 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->assign ( 'resume', get_down_resume ( $offset, $perpage, $wheresql ) );
	if ($total_val > $perpage) {
		$smarty->assign ( 'page', $page->show ( 3 ) ); //分頁符
	}
	$smarty->display ( 'member_company/company_down_resume.htm' );
}
//已下載簡歷 刪除,添加到人才庫
if ($act == 'down_resume_perform') {
	$delete = trim ( $_POST ['delete'] );
	$shift = trim ( $_REQUEST ['shift'] );
	$resume_id_arr = trim ( $_REQUEST ['y_id'] ) ? $_REQUEST ['y_id'] : showmsg ( "你沒有選擇簡歷！", 1 );
	if ($delete) {
		! del_down_resume ( $resume_id_arr, $_SESSION ['uid'] ) ? showmsg ( "刪除失敗！", 0 ) : showmsg ( "刪除成功！", 2 );
	}
	if ($shift) {
		! add_resume_library ( $resume_id_arr, $_SESSION ['uid'] ) ? showmsg ( "操作失敗！", 0 ) : showmsg ( "成功添加的人才庫中！", 2 );
	}
}
//人才庫
if ($act == 'resume_library_lsit') {
	require_once (QISHI_ROOT_PATH . 'include/page.class.php');
	$perpage = 10;
	$wheresql = " INNER JOIN  " . table ( 'resume' ) . " ON " . table ( 'company_resume_library' ) . ".resume_id=" . table ( 'resume' ) . ".id  AND " . table ( 'company_resume_library' ) . ".company_uid=" . intval ( $_SESSION ['uid'] ) . " ";
	$total_sql = "SELECT COUNT(*) AS num FROM " . table ( 'company_resume_library' ) . $wheresql;
	$total_val = get_total ( $total_sql );
	$page = new page ( array ('total' => $total_val, 'perpage' => $perpage ) );
	$currenpage = $page->nowindex;
	$offset = ($currenpage - 1) * $perpage;
	$smarty->assign ( 'title', '企業人才庫 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->assign ( 'resume', get_resume_library ( $offset, $perpage, $wheresql ) );
	if ($total_val > $perpage) {
		$smarty->assign ( 'page', $page->show ( 3 ) ); //分頁符
	}
	$smarty->display ( 'member_company/company_resume_library.htm' );
}
//刪除人才庫中的人才
if ($act == 'resume_library_del') {
	$yid = trim ( $_REQUEST ['y_id'] ) ? $_REQUEST ['y_id'] : showmsg ( "你沒有選擇簡歷！", 1 );
	$delete = trim ( $_POST ['delete'] );
	$delete ? (! del_resume_library ( $yid, $_SESSION ['uid'] ) ? showmsg ( "刪除失敗！", 0 ) : showmsg ( "刪除成功！", 2 )) : '';
}
//邀請面試選擇條件頁面
if ($act == 'invitation_interview') {
	$resume_id = $_GET ['resume_id'];
	if ($resume_id && intval ( $resume_id ) == $resume_id) {
		$user_jobs = get_user_jobs ( $_SESSION ['uid'] );
		if (count ( $user_jobs ) == 0)
			showmsg ( "邀請失敗，你沒有發布招聘信息或者信息沒有審核通過，暫時不能邀請面試", 1, $link, false );
		$link [0] ['text'] = "返回上一頁！";
		$link [0] ['href'] = $_SERVER ['HTTP_REFERER'];
		$link [1] ['text'] = "查看我發起的面試邀請";
		$link [1] ['href'] = '?act=invitation_interview_lsit';
		if (check_invitation_interview ( $resume_id, $_SESSION ['uid'] ))
			showmsg ( "您已經邀請過 " . $_GET ['resume_name'] . " 啦，不能重復邀請!", 1, $link, false );
		$points_rule = get_cache ( 'members_points_rule' );
		$resumeusql = "select * from " . table ( 'resume' ) . "  WHERE  id ='" . intval ( $resume_id ) . "'";
		$resume = $db->getone ( $resumeusql );
		if ($resume ['talent'] == '1')
			$points = $points_rule ['interview_invite']; //1為普通人才，2為高級人才
		if ($resume ['talent'] == '2')
			$points = $points_rule ['interview_invite_advanced'];
		$smarty->assign ( 'user_jobs', $user_jobs );
		$smarty->assign ( 'url', $_SERVER ['HTTP_REFERER'] );
		$smarty->assign ( 'points', $points );
		$smarty->assign ( 'fullname', $resume ['fullname'] );
		$smarty->assign ( 'resume_id', $resume ['id'] );
		$smarty->assign ( 'resume_uid', $resume ['uid'] );
		$smarty->assign ( 'resume_url', url_rewrite ( 'resume-show', array ('id0' => $resume ['id'] ) ) );
		$smarty->assign ( 'company_profile', get_company_profile ( $_SESSION ['uid'] ) );
		$smarty->display ( 'member_company/company_invitation_interview_add.htm' );
	}
}
//邀請面試
if ($act == 'add_invitation_interview') {
	$resume_id = $_POST ['resume_id'];
	if ($resume_id && intval ( $resume_id ) == $resume_id) {
		$link [0] ['text'] = "返回上一頁！";
		$link [0] ['href'] = $_POST ['url'];
		$link [1] ['text'] = "查看我發起的面試邀請";
		$link [1] ['href'] = '?act=invitation_interview_lsit';
		$points = intval ( $_POST ['points'] );
		if (get_user_points ( $_SESSION ['uid'] ) < $points)
			showmsg ( "你的" . $_CFG ['points_byname'] . "不足，請充值后再進行操作", 1 );
		$addarr ['resume_id'] = $resume_id;
		$addarr ['resume_uid'] = intval ( $_POST ['resume_uid'] );
		$addarr ['company_id'] = intval ( $_POST ['company_id'] );
		$addarr ['company_uid'] = $_SESSION ['uid'];
		$addarr ['jobs_name'] = implode ( ',', $_POST ['jobs_name'] );
		$addarr ['companyname'] = $_POST ['companyname'];
		//$addarr['fullname']=$_POST['fullname'];
		$addarr ['notes'] = $_POST ['notes'];
		$addarr ['personal_look'] = 1;
		$addarr ['addtime'] = $timestamp;
		if (inserttable ( table ( 'company_invitation_interview' ), $addarr )) {
			if (! report_deal ( $_SESSION ['uid'], 2, intval ( $_POST ['points'] ), "邀請:" . $_POST ['resume_name'] . "面試， 扣除：" . intval ( $_POST ['points'] ) . "" ))
				showmsg ( "你的" . $_CFG ['points_byname'] . "不足，請充值后再進行操作", 1 );
			$mailconfig = get_cache ( 'mailconfig' );
			if ($mailconfig ['set_invite'] == "1") {
				require_once (QISHI_ROOT_PATH . 'include/fun_resume.php');
				$resume_basic = get_resume_basic ( $addarr ['resume_uid'] ); //簡歷基本資料
				if ($resume_basic ['email_notify'] == '1') {
					require_once (QISHI_ROOT_PATH . 'include/fun_user.php');
					asyn_sendmail ( $_CFG ['site_domain'] . $_CFG ['site_dir'] . "asyn_mail.php?uid=" . $_SESSION ['uid'] . "&key=" . asyn_userkey ( $_SESSION ['uid'] ) . "&act=set_invite&companyname=" . $addarr ['companyname'] . "&email=" . $resume_basic ['email'] );
				}
				showmsg ( "邀請成功！", 2, $link, false );
			}
		} else {
			showmsg ( "邀請失敗！", 1 );
		}
	}
}
//已邀請面試列表
if ($act == 'invitation_interview_lsit') {
	require_once (QISHI_ROOT_PATH . 'include/page.class.php');
	$perpage = 10;
	$wheresql = " INNER JOIN  " . table ( 'resume' ) . " ON " . table ( 'company_invitation_interview' ) . ".company_uid=" . intval ( $_SESSION ['uid'] ) . " AND " . table ( 'company_invitation_interview' ) . ".resume_id=" . table ( 'resume' ) . ".id ";
	$total_sql = "SELECT COUNT(*) AS num FROM " . table ( 'company_invitation_interview' ) . $wheresql;
	$total_val = get_total ( $total_sql );
	$page = new page ( array ('total' => $total_val, 'perpage' => $perpage ) );
	$currenpage = $page->nowindex;
	$offset = ($currenpage - 1) * $perpage;
	$smarty->assign ( 'title', '我發起的面試邀請 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->assign ( 'resume', get_invitation_interview ( $offset, $perpage, $wheresql ) );
	if ($total_val > $perpage) {
		$smarty->assign ( 'page', $page->show ( 3 ) ); //分頁符
	}
	$smarty->display ( 'member_company/company_invitation_interview.htm' );
}
//刪除面試邀請信息
if ($act == 'invitation_interview_del') {
	$yid = trim ( $_REQUEST ['y_id'] ) ? $_REQUEST ['y_id'] : showmsg ( "你沒有選擇項目！", 1 );
	$delete = trim ( $_POST ['delete'] );
	$delete ? (! del_invitation_interview ( $yid, $_SESSION ['uid'] ) ? showmsg ( "刪除失敗！", 0 ) : showmsg ( "刪除成功！", 2 )) : '';
}
//*************************************************財務中心**********************
//賬戶明細
if ($act == 'points_report') {
	require_once (QISHI_ROOT_PATH . 'include/page.class.php');
	$i_type = trim ( $_GET ['i_type'] );
	$wheresql = " WHERE uid='" . $_SESSION ['uid'] . "' ";
	if ($i_type != '' && is_numeric ( $i_type )) {
		$wheresql .= " AND i_type='" . $i_type . "' ";
	}
	$perpage = 15;
	$total_sql = "SELECT COUNT(*) AS num FROM " . table ( 'members_points_report' ) . $wheresql;
	$total_val = get_total ( $total_sql );
	$page = new page ( array ('total' => $total_val, 'perpage' => $perpage ) );
	$currenpage = $page->nowindex;
	$offset = ($currenpage - 1) * $perpage;
	$smarty->assign ( 'title', '賬戶明細 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->assign ( 'act', $act );
	$smarty->assign ( 'i_type', $i_type );
	$smarty->assign ( 'points_report', get_user_points_report ( $offset, $perpage, $wheresql ) );
	if ($total_val > $perpage) {
		$smarty->assign ( 'page', $page->show ( 3 ) ); //分頁符
	}
	$smarty->display ( 'member_company/company_points_report.htm' );
}
//充值記錄
if ($act == 'payment_report') {
	require_once (QISHI_ROOT_PATH . 'include/page.class.php');
	$is_paid = trim ( $_GET ['is_paid'] );
	$wheresql = " WHERE uid='" . $_SESSION ['uid'] . "' ";
	if ($is_paid != '' && is_numeric ( $is_paid )) {
		$wheresql .= " AND is_paid='" . $is_paid . "' ";
	}
	$perpage = 10;
	$total_sql = "SELECT COUNT(*) AS num FROM " . table ( 'payment_log' ) . $wheresql;
	$total_val = get_total ( $total_sql );
	$page = new page ( array ('total' => $total_val, 'perpage' => $perpage ) );
	$currenpage = $page->nowindex;
	$offset = ($currenpage - 1) * $perpage;
	$smarty->assign ( 'title', '充值記錄 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->assign ( 'act', $act );
	$smarty->assign ( 'is_paid', $is_paid );
	$smarty->assign ( 'payment', get_payment_all ( $offset, $perpage, $wheresql ) );
	if ($total_val > $perpage) {
		$smarty->assign ( 'page', $page->show ( 3 ) ); //分頁符
	}
	$smarty->display ( 'member_company/company_payment_report.htm' );
}
//積分規則
if ($act == 'points_rule') {
	$smarty->assign ( 'title', '消費規則 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->assign ( 'points', get_points_rule () );
	$smarty->display ( 'member_company/company_points_rule.htm' );
}
//在線充值申請
if ($act == 'payment') {
	$smarty->assign ( 'title', '在線充值 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->assign ( 'payment', get_payment () );
	$smarty->display ( 'member_company/company_payment_application.htm' );
}
//在線充值提交
if ($act == 'payment1') {
	if (get_user_payment ( $_SESSION ['uid'], 1 )) {
		$link [0] ['text'] = "立即查看";
		$link [0] ['href'] = '?act=payment_report&is_paid=1';
		showmsg ( "你有充值訂單里有未處理訂單，請處理后再次申請！", 1, $link, true, 8 );
	}
	$amount = (trim ( $_POST ['amount'] )) . (intval ( $_POST ['amount'] )) ? trim ( $_POST ['amount'] ) : showmsg ( '請填寫充值金額！', 1 );
	($amount < $_CFG ['payment_min']) ? showmsg ( "單筆充值金額不能少于 " . $_CFG ['payment_min'] . " 元！", 1 ) : '';
	$payment_name = empty ( $_POST ['payment_name'] ) ? showmsg ( "請選擇付款方式！", 1 ) : $_POST ['payment_name'];
	$paymenttpye = get_payment_info ( $payment_name );
	if (! $paymenttpye)
		showmsg ( "支付方式錯誤！", 0 );
	$fee = number_format ( ($amount / 100) * $paymenttpye ['fee'], 1, '.', '' ); //手續費
	$order ['oid'] = date ( 'Ymd', time () ) . "-" . $paymenttpye ['partnerid'] . "-" . date ( 'His', time () ); //訂單號
	$order ['v_url'] = $_CFG ['site_domain'] . $_CFG ['site_dir'] . "respond.php?code=" . $paymenttpye ['typename'];
	$order ['v_amount'] = $amount + $fee;
	if ($payment_name != 'remittance') //假如是非線下支付，
{
		require_once (QISHI_ROOT_PATH . "include/payment/" . $paymenttpye ['typename'] . ".php");
		$payment_form = get_code ( $order, $paymenttpye );
		if (! $payment_form)
			showmsg ( "在線支付參數錯誤！", 0 );
	}
	$points = $amount * $_CFG ['payment_rate'];
	if (! add_payment ( $_SESSION ['uid'], $order ['oid'], $amount, $payment_name, $points, $timestamp ))
		showmsg ( "添加充值記錄失敗！", 0 );
	$smarty->assign ( 'title', '在線充值 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->assign ( 'fee', $fee );
	$smarty->assign ( 'amount', $amount );
	$smarty->assign ( 'byname', $paymenttpye );
	$smarty->assign ( 'payment_form', $payment_form );
	$smarty->display ( 'member_company/company_payment_pay.htm' );
	//充值發送郵件
	$mailconfig = get_cache ( 'mailconfig' );
	if ($mailconfig ['set_order'] == "1") {
		require_once (QISHI_ROOT_PATH . 'include/fun_user.php');
		asyn_sendmail ( $_CFG ['site_domain'] . $_CFG ['site_dir'] . "asyn_mail.php?uid=" . $_SESSION ['uid'] . "&key=" . asyn_userkey ( $_SESSION ['uid'] ) . "&act=set_order&paymenttpye=" . $paymenttpye ['byname'] . "&amount=" . $amount );
	}

	//郵件發送完畢
}
//在線付款提交(從付款記錄付款)
if ($act == 'payment2') {
	$id = trim ( $_GET ['id'] );
	$paymentinfo = get_payment_one ( $_SESSION ['uid'], $id ); //如果此充值記錄已存在，直接付款，無需再次增加付款記錄
	$amount = $paymentinfo ['amount'];
	$payment_name = $paymentinfo ['payment_name'];
	$paymenttpye = get_payment_info ( $payment_name );
	if (! $paymenttpye)
		showmsg ( "支付方式錯誤！", 0 );
	$fee = number_format ( ($amount / 100) * $paymenttpye ['fee'], 1, '.', '' ); //手續費
	$order ['oid'] = $paymentinfo ['oid']; //訂單號
	$order ['v_url'] = $_CFG ['site_domain'] . $_CFG ['site_dir'] . "respond.php?code=" . $paymenttpye ['typename'];
	$order ['v_amount'] = $amount + $fee;
	if ($payment_name != 'remittance') //假如是非線下支付，
{
		require_once (QISHI_ROOT_PATH . "include/payment/" . $paymenttpye ['typename'] . ".php");
		$payment_form = get_code ( $order, $paymenttpye );
		if (! $payment_form)
			showmsg ( "在線支付參數錯誤！", 0 );
	}
	$points = $amount * $_CFG ['payment_rate'];
	$smarty->assign ( 'title', '在線充值 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->assign ( 'fee', $fee );
	$smarty->assign ( 'amount', $amount );
	$smarty->assign ( 'byname', $paymenttpye );
	$smarty->assign ( 'payment_form', $payment_form );
	$smarty->display ( 'member_company/company_payment_pay.htm' );
}
//取消充值
if ($act == 'payment_del') {
	$link [0] ['text'] = "返回上一頁";
	$link [0] ['href'] = '?act=payment_report';
	$id = trim ( $_GET ['id'] );
	del_payment ( $_SESSION ['uid'], $id ) ? showmsg ( '取消成功！', 2, $link ) : showmsg ( '取消失敗！', 1 );
}
//*************************************************公司資料**********************
//公司資料
if ($act == 'company_profile') {
	$smarty->assign ( 'title', '企業資料管理 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->assign ( 'company_profile', get_company_profile ( $_SESSION ['uid'] ) );
	$smarty->assign ( 'company_profile_contents', get_company_profile_contents ( $_SESSION ['uid'] ) );
	$smarty->assign ( 'nature', get_jobs_corporation () );
	$smarty->assign ( 'trade', get_jobs_trade () );
	$smarty->assign ( 'area', get_jobs_area () );
	$smarty->assign ( 'scale', get_jobs_scale () );
	$smarty->display ( 'member_company/company_profile.htm' );
}
//保存企業資料
if ($act == 'company_profile_save') {
	$_POST = htmldecode ( $_POST );
	$company_profile = get_company_profile ( $_SESSION ['uid'] );
	$setsqlarr = array ();
	$contents = array ();
	
	$uid = $_SESSION ['uid'];
	$setsqlarr ['uid'] = trim ( $_SESSION ['uid'] );
	$setsqlarr ['company_name_en'] = trim ( $_POST ['company_name_en'] );
	$setsqlarr ['company_name_cn'] = trim ( $_POST ['company_name_cn'] );
	if ('' == $setsqlarr ['company_name_cn'] && '' == $setsqlarr ['company_name_en']) {
		showmsg ( '您沒有輸入公司名稱！', 1 );
	}
	$setsqlarr ['trade'] = trim ( $_POST ['trade'] ) ? trim ( $_POST ['trade'] ) : showmsg ( '您沒有輸入所屬行業！', 1 );
	$setsqlarr ['trade_option'] = trim ( $_POST ['trade_option'] );
	$setsqlarr ['stuff_number'] = trim ( $_POST ['stuff_number'] ) ? trim ( $_POST ['stuff_number'] ) : showmsg ( '您沒有輸入現有僱員人數！', 1 );
	$setsqlarr ['school_number'] = trim ( $_POST ['school_number'] );
	$setsqlarr ['reg_number_pre'] = trim ( $_POST ['reg_number_pre'] );
	$setsqlarr ['reg_number_suf'] = trim ( $_POST ['reg_number_suf'] );
	
	$setsqlarr ['contact_gender_en'] = trim ( $_POST ['contact_gender_en'] ) ? trim ( $_POST ['contact_gender_en'] ) : 1;
	$setsqlarr ['contact_gender_cn'] = trim ( $_POST ['contact_gender_cn'] ) ? trim ( $_POST ['contact_gender_cn'] ) : 1;
	$setsqlarr ['contact_en'] = trim ( $_POST ['contact_en'] );
	$setsqlarr ['contact_cn'] = trim ( $_POST ['contact_cn'] );
	if ('' == $setsqlarr ['contact_cn'] && '' == $setsqlarr ['contact_en']) {
		showmsg ( '您沒有輸入聯絡人姓名！', 1 );
	}
	$setsqlarr ['telephone'] = trim ( $_POST ['telephone'] );
	$setsqlarr ['telephone_inline'] = trim ( $_POST ['telephone_inline'] );
	$setsqlarr ['telephone_option'] = trim ( $_POST ['telephone_option'] ) ? trim ( $_POST ['telephone_option'] ) : 1;
	if ('' == $setsqlarr ['telephone'] && '' == $setsqlarr ['telephone_inline']) {
		showmsg ( '您沒有輸入電話號碼！', 1 );
	}
	$setsqlarr ['email'] = trim ( $_POST ['email'] ) ? trim ( $_POST ['email'] ) : showmsg ( '您沒有輸入聯系郵箱！', 1 );
	$setsqlarr ['address_1_en'] = trim ( $_POST ['address_1_en'] );
	$setsqlarr ['address_2_en'] = trim ( $_POST ['address_2_en'] );
	$setsqlarr ['address_3_en'] = trim ( $_POST ['address_3_en'] );
	$setsqlarr ['address_1_cn'] = trim ( $_POST ['address_1_cn'] );
	$setsqlarr ['address_2_cn'] = trim ( $_POST ['address_2_cn'] );
	$setsqlarr ['address_3_cn'] = trim ( $_POST ['address_3_cn'] );
	if ('' == $setsqlarr ['address_1_en'] && '' == $setsqlarr ['address_2_en'] && '' == $setsqlarr ['address_3_en'] && '' == $setsqlarr ['address_1_cn'] && '' == $setsqlarr ['address_2_cn'] && '' == $setsqlarr ['address_3_cn']) {
		showmsg ( '您沒有輸入公司地址！', 1 );
	}
	$setsqlarr ['fax'] = trim ( $_POST ['fax'] );
	$tablename = table ( 'company_profile' );
	$link [0] ['text'] = "查看修改結果";
	$link [0] ['href'] = '?act=company_profile';
	$link [1] ['text'] = "發布招聘信息";
	$link [1] ['href'] = "?act=addjobs";
	$link [2] ['text'] = "會員中心首頁";
	$link [2] ['href'] = "?";
	
	if ($company_profile) {
		$wheresql = "uid='" . $uid . "'";
		if (updatetable ( $tablename, $setsqlarr, $wheresql )) {
			unset ( $setsqlarr, $contents );
			showmsg ( "保存成功！", 2, $link );
		} else {
			unset ( $setsqlarr, $contents );
			showmsg ( "保存失敗！", 0 );
		}
	} else {
		$setsqlarr ['addtime'] = $timestamp;
		if (inserttable ( $tablename, $setsqlarr )) {
			unset ( $setsqlarr, $contents );
			showmsg ( "保存成功！", 2, $link );
		} else {
			unset ( $setsqlarr, $contents );
			showmsg ( "保存失敗！", 0 );
		}
	}
}
//營業執照
if ($act == 'company_auth') {
	$link [0] ['text'] = "完善企業資料";
	$link [0] ['href'] = '?act=company_profile';
	$link [1] ['text'] = "管理首頁";
	$link [1] ['href'] = '?';
	$company_profile = get_company_profile ( $_SESSION ['uid'] );
	if (! $company_profile)
		showmsg ( "請完善您的企業資料再上傳營業執照！", 1, $link );
	$smarty->assign ( 'title', '營業執照 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->assign ( 'points', get_cache ( 'members_points_rule' ) );
	$smarty->assign ( 'company_profile', $company_profile );
	$smarty->display ( 'member_company/company_auth.htm' );
}
//保存營業執照
if ($act == 'company_auth_save') {
	require_once (QISHI_ROOT_PATH . 'include/upload_img.php');
	$setsqlarr ['license'] = trim ( $_POST ['license'] ) ? trim ( $_POST ['license'] ) : showmsg ( '您沒有輸入營業執照注冊號！', 1 );
	$setsqlarr ['audit'] = 2; //添加默認審核中..
	! $_FILES ['certificate_img'] ['name'] ? showmsg ( '請上傳圖片！', 1 ) : "";
	$certificate_dir = substr ( $_CFG ['certificate_dir'], mb_strlen ( $_CFG ['site_dir'] ) ); //絕對路徑轉化成相對路徑 
	$setsqlarr ['certificate_img'] = _asUpFiles ( $certificate_dir, "certificate_img", $_CFG ['certificate_max_size'], 'gif/jpg/bmp/png', true );
	if ($setsqlarr ['certificate_img']) {
		$auth = get_company_profile ( $_SESSION ['uid'] ); //獲取原始圖片
		@unlink ( $certificate_dir . $auth ['certificate_img'] ); //先刪除原始圖片
		$wheresql = "uid='" . $_SESSION ['uid'] . "'";
		! updatetable ( table ( 'company_profile' ), $setsqlarr, $wheresql ) ? showmsg ( '保存失敗！', 1 ) : showmsg ( '保存成功，請耐心等待管理員審核！', 2 );
	} else {
		showmsg ( '保存失敗！', 1 );
	}
}
//加入特別推薦
if ($act == 'recommend') {
	$company_profile = get_company_profile ( $_SESSION ['uid'] );
	if (! $company_profile)
		showmsg ( "請完善您的企業資料再加入特別推薦！", 1 );
	if ($company_profile ['recommend'] == "1")
		showmsg ( "您的企業目前已經加入特別推薦，無需再次申請！", 1 );
	$points = get_cache ( 'members_points_rule' ); //獲取積分消費規則
	$smarty->assign ( 'title', '加入特別推薦企業 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->assign ( 'points', $points ['company_recommend'] );
	$smarty->display ( 'member_company/company_recommend.htm' );
}
//開通特別推薦
if ($act == 'recommend_add') {
	$link [0] ['text'] = "返回會員中心首頁";
	$link [0] ['href'] = '?act=';
	$points = get_cache ( 'members_points_rule' ); //獲取積分消費規則
	$user_points = get_user_points ( $_SESSION ['uid'] ); //獲取會員所有積分
	$points ['company_recommend'] > $user_points ? showmsg ( "你的" . $_CFG ['points_byname'] . "不足，請充值后再進行相關操作！", 0 ) . (exit ()) : '';
	! report_deal ( $_SESSION ['uid'], 2, $points ['company_recommend'], "開通特別企業推薦扣除" . $points ['company_recommend'] . "" ) ? showmsg ( "更新積分明細失敗！", 0 ) : '';
	$setsqlarr ['recommend'] = 1;
	$wheresql = "uid='" . $_SESSION ['uid'] . "'";
	if (updatetable ( table ( 'company_profile' ), $setsqlarr, $wheresql )) {
		//發送郵件
		$mailconfig = get_cache ( 'mailconfig' );
		if ($mailconfig ['set_addrecommend'] == "1") {
			require_once (QISHI_ROOT_PATH . 'include/fun_user.php');
			asyn_sendmail ( $_CFG ['site_domain'] . $_CFG ['site_dir'] . "asyn_mail.php?uid=" . $_SESSION ['uid'] . "&key=" . asyn_userkey ( $_SESSION ['uid'] ) . "&act=set_addrecommend" );
		}
		//發送郵件完畢
		showmsg ( '成功開通！', 2, $link );
	} else {
		showmsg ( '開通失敗！', 1 );
	}
}
//電子地圖
if ($act == 'company_map') {
	$link [0] ['text'] = "填寫企業資料";
	$link [0] ['href'] = '?act=company_profile';
	$company_profile = get_company_profile ( $_SESSION ['uid'] );
	if (! $company_profile)
		showmsg ( "請完善您的企業資料再設置電子地圖！", 1, $link );
	if ($company_profile ['map_open'] == "1") //假如已經開通
{
		$act = "company_map_set";
	} else {
		$points = get_cache ( 'members_points_rule' ); //獲取積分消費規則
		$smarty->assign ( 'title', '開通電子地圖 - 企業會員中心 - ' . $_CFG ['site_name'] );
		$smarty->assign ( 'points', $points ['company_map'] );
		$smarty->display ( 'member_company/company_map_open.htm' );
	}
}
//開通電子地圖
if ($act == 'company_map_open') {
	$link [0] ['text'] = "立即設置電子地圖";
	$link [0] ['href'] = '?act=company_map_set';
	$company_profile = get_company_profile ( $_SESSION ['uid'] );
	if (! $company_profile)
		showmsg ( "請完善您的企業資料再設置電子地圖！", 1 );
	if ($company_profile ['map_open'] == "1")
		showmsg ( '成功開通！', 2, $link );
	$wheresql = "uid='" . $_SESSION ['uid'] . "'";
	$setsqlarr ['map_open'] = 1; //開通電子地圖
	$points = get_cache ( 'members_points_rule' ); //獲取積分消費規則
	$user_points = get_user_points ( $_SESSION ['uid'] ); //獲取會員所有積分
	$points ['company_map'] > $user_points ? showmsg ( "你的" . $_CFG ['points_byname'] . "不足，請充值后再進行相關操作！", 0, $link, true, 8 ) . (exit ()) : '';
	! report_deal ( $_SESSION ['uid'], 2, $points ['company_map'], "開通電子地圖扣除" . $points ['company_map'] . "" ) ? showmsg ( "更新積分明細失敗！", 0 ) : '';
	if (updatetable ( table ( 'company_profile' ), $setsqlarr, $wheresql )) {
		//發送郵件
		$mailconfig = get_cache ( 'mailconfig' );
		if ($mailconfig ['set_addmap'] == "1") {
			require_once (QISHI_ROOT_PATH . 'include/fun_user.php');
			asyn_sendmail ( $_CFG ['site_domain'] . $_CFG ['site_dir'] . "asyn_mail.php?uid=" . $_SESSION ['uid'] . "&key=" . asyn_userkey ( $_SESSION ['uid'] ) . "&act=set_addmap" );
		}
		//發送郵件完畢
		showmsg ( '成功開通！', 2, $link );
	} else {
		showmsg ( '開通失敗！', 1 );
	}
}
//設置地圖
if ($act == 'company_map_set') {
	$smarty->assign ( 'title', '設置電子地圖 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->assign ( 'company_profile', get_company_profile ( $_SESSION ['uid'] ) );
	$smarty->display ( 'member_company/company_map_set.htm' );
}
//保存電子地圖設置
if ($act == 'company_map_set_save') {
	$setsqlarr ['map_x'] = trim ( $_POST ['x'] ) ? trim ( $_POST ['x'] ) : showmsg ( '請先點擊“在地圖上標記我的位置”按鈕，然后再點擊保存我的位置進行保存！', 1 );
	$setsqlarr ['map_y'] = trim ( $_POST ['y'] ) ? trim ( $_POST ['y'] ) : showmsg ( '請先點擊“在地圖上標記我的位置”按鈕，然后再點擊保存我的位置進行保存！', 1 );
	$setsqlarr ['map_zoom'] = trim ( $_POST ['zoom'] );
	$wheresql = "uid='" . $_SESSION ['uid'] . "'";
	! updatetable ( table ( 'company_profile' ), $setsqlarr, $wheresql ) ? showmsg ( '保存失敗！', 1 ) : showmsg ( '保存成功', 2 );
}
//************************************賬號管理
//修改會員狀態頁面
if ($act == 'user_status') {
	$smarty->assign ( 'title', '賬號狀態 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->display ( 'member_company/company_user_status.htm' );
}
//保存會員狀態
if ($act == 'user_status_save') {
	! set_user_status ( $_POST ['status'], $_SESSION ['uid'] ) ? showmsg ( '保存失敗！', 1 ) : showmsg ( '保存成功', 2 );
}
//修改密碼
if ($act == 'password_edit') {
	$smarty->assign ( 'title', '修改密碼 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->display ( 'member_company/company_password.htm' );
}
//保存修改密碼
if ($act == 'save_password') {
	require_once (QISHI_ROOT_PATH . 'include/fun_user.php');
	$arr ['username'] = $_SESSION ['username'];
	$arr ['oldpassword'] = trim ( $_POST ['oldpassword'] ) ? trim ( $_POST ['oldpassword'] ) : showmsg ( '請輸入舊密碼！', 1 );
	$arr ['password'] = trim ( $_POST ['password'] ) ? trim ( $_POST ['password'] ) : showmsg ( '請輸入新密碼！', 1 );
	if ($arr ['password'] != trim ( $_POST ['password1'] ))
		showmsg ( '兩次輸入密碼不相同，請重新輸入！', 1 );
	$info = edit_password ( $arr );
	if ($info == - 1)
		showmsg ( '舊密碼輸入錯誤，請重新輸入！', 1 );
	if ($info == $_SESSION ['username']) {
		//發送郵件
		$mailconfig = get_cache ( 'mailconfig' );
		if ($mailconfig ['set_editpwd'] == "1") {
			require_once (QISHI_ROOT_PATH . 'include/fun_user.php');
			asyn_sendmail ( $_CFG ['site_domain'] . $_CFG ['site_dir'] . "asyn_mail.php?uid=" . $_SESSION ['uid'] . "&key=" . asyn_userkey ( $_SESSION ['uid'] ) . "&act=set_editpwd&password=" . $arr ['password'] );
		}
		//郵件發送完畢
		showmsg ( '密碼修改成功！', 2 );
	}
}
//用戶反饋
if ($act == 'feedback') {
	$smarty->assign ( 'title', '用戶反饋 - 企業會員中心 - ' . $_CFG ['site_name'] );
	$smarty->assign ( 'feedback', get_feedback ( $_SESSION ['uid'] ) );
	$smarty->display ( 'member_company/company_feedback.htm' );
}
//保存用戶反饋
if ($act == 'feedback_save') {
	$get_feedback = get_feedback ( $_SESSION ['uid'] );
	if (count ( $get_feedback ) >= 5) {
		showmsg ( '反饋信息不能超過5條！', 1 );
		exit ();
	}
	$_POST = htmldecode ( $_POST );
	$setsqlarr ['infotype'] = trim ( $_POST ['infotype'] );
	$setsqlarr ['feedback'] = trim ( $_POST ['feedback'] );
	$setsqlarr ['uid'] = $_SESSION ['uid'];
	$setsqlarr ['usertype'] = $_SESSION ['utype'];
	$setsqlarr ['username'] = $_SESSION ['username'];
	$setsqlarr ['addtime'] = $timestamp;
	! inserttable ( table ( 'feedback' ), $setsqlarr ) ? showmsg ( "添加失敗！", 0 ) : showmsg ( "添加成功，請等待管理員回復！", 2 );
}
//刪除用戶反饋
if ($act == 'del_feedback') {
	$id = trim ( $_GET ['id'] );
	del_feedback ( $id, $_SESSION ['uid'] ) ? showmsg ( '刪除成功！', 2 ) : showmsg ( '刪除失敗！', 1 );
}
?>
